package com.kotlin.usercenter.presenter

import com.kotlin.base.ext.execute
import com.kotlin.base.presenter.BasePresenter
import com.kotlin.base.rx.BaseSubscriber
import com.kotlin.usercenter.data.protocol.UseInfo
import com.kotlin.usercenter.presenter.view.LoginView
import com.kotlin.usercenter.service.UserService
import javax.inject.Inject

class LoginPresenter @Inject constructor() : BasePresenter<LoginView>() {

    @Inject
    lateinit var userService: UserService

    fun login(mobile: String, pwd: String) {
        mView.showLoading()
        userService.login(mobile, pwd).execute(object : BaseSubscriber<UseInfo>(mView) {
            override fun onNext(t: UseInfo) {
                mView.onLoginResult(t)
            }
        }, lifecycleProvider)
    }
}